// 云网盘相关类型定义

/**
 * 文件信息
 */
export interface CdFileVo {
  fileId: number
  fileName: string
  originalName: string
  fileExtension: string
  fileSize: number
  fileType: string
  mimeType: string
  fileHash: string
  folderId: number
  filePath: string
  ossId?: number
  downloadCount: number
  viewCount: number
  isShared: boolean
  shareCode?: string
  shareExpireTime?: string
  accessLevel: string
  version: number
  parentFileId?: number
  status: string
  createTime: string
  updateTime: string
  fileSizeFormatted: string
  fileUrl: string
  previewUrl: string
  canPreview: boolean
  canDownload: boolean
  folderPath?: string
  isOwned?: boolean // 是否为当前用户拥有（true：自己的文件，false：授权查看的文件）
}

/**
 * 文件夹信息
 */
export interface CdFolderVo {
  folderId: number | string
  folderName: string
  parentId: number | string
  folderPath: string
  folderType: string
  ownerId: number
  projectId?: number
  folderSize: number
  fileCount: number
  folderCount: number
  isShared: boolean
  shareCode?: string
  shareExpireTime?: string
  accessLevel: string
  status: string
  createTime: string
  updateTime: string
  folderSizeFormatted: string
  children?: CdFolderVo[]
  expanded?: boolean
  leaf?: boolean
  projectName?: string
  ownerName?: string
  isOwned?: boolean // 是否为当前用户拥有（true：自己的文件夹，false：授权查看的文件夹）
}

/**
 * 分享信息
 */
export interface CdShareVo {
  shareId: number
  shareCode: string
  shareType: string
  resourceId: number
  shareName: string
  sharePassword?: string
  accessCount: number
  downloadCount: number
  expireTime?: string
  isPermanent: boolean
  accessLevel: string
  allowDownload: boolean
  allowPreview: boolean
  status: string
  createTime: string
  updateTime: string
  shareUrl: string
  resourceName: string
  isExpired?: boolean
  remainingDays?: number
}

/**
 * 权限信息
 */
export interface CdPermissionVo {
  permissionId: number | string
  resourceType: string
  resourceId: number | string
  userId?: number | string
  roleId?: number | string
  permissionType: string
  grantType: string
  status: string
  createTime?: string
  updateTime?: string
  userName?: string
  roleName?: string
}

/**
 * 用户存储统计
 */
export interface CdUserStorageVo {
  storageId: number
  userId: number
  totalSize: number
  usedSize: number
  fileCount: number
  folderCount: number
  lastCleanupTime?: string
  status: string
  createTime: string
  updateTime: string
  totalSizeFormatted: string
  usedSizeFormatted: string
  usagePercentage: number
}

/**
 * 文件类型枚举
 */
export enum FileTypeEnum {
  IMAGE = 'image',
  DOCUMENT = 'document',
  VIDEO = 'video',
  AUDIO = 'audio',
  ARCHIVE = 'archive',
  OTHER = 'other'
}

/**
 * 分享类型枚举
 */
export enum ShareTypeEnum {
  FILE = 'file',
  FOLDER = 'folder'
}

/**
 * 权限类型枚举
 */
export enum PermissionTypeEnum {
  READ = 'read',
  WRITE = 'write',
  DELETE = 'delete',
  SHARE = 'share',
  MANAGE = 'manage'
}

/**
 * 访问级别枚举
 */
export enum AccessLevelEnum {
  PRIVATE = 'private',
  PUBLIC = 'public',
  RESTRICTED = 'restricted',
  PASSWORD = 'password'
}

/**
 * 文件夹类型枚举
 */
export enum FolderTypeEnum {
  PERSONAL = 'personal',
  SHARED = 'shared',
  PROJECT = 'project'
}

/**
 * 文件上传进度
 */
export interface UploadProgress {
  loaded: number
  total: number
  percentage: number
  status: 'uploading' | 'success' | 'error'
  error?: string
}

/**
 * 文件操作类型
 */
export type FileOperationType = 'rename' | 'move' | 'copy' | 'delete' | 'share'

/**
 * 文件夹操作类型
 */
export type FolderOperationType = 'rename' | 'move' | 'copy' | 'delete' | 'share'

/**
 * 文件选择项
 */
export interface FileSelectionItem {
  type: 'file' | 'folder'
  id: number
  name: string
  size?: number
  sizeFormatted?: string
  icon?: string
}

/**
 * 拖拽数据
 */
export interface DragData {
  type: 'file' | 'folder'
  items: FileSelectionItem[]
  sourceFolderId: number
}

/**
 * 文件预览配置
 */
export interface PreviewConfig {
  fileId: number
  fileName: string
  fileUrl: string
  fileType: string
  mimeType: string
  canPreview: boolean
  canDownload: boolean
}

/**
 * 分享配置
 */
export interface ShareConfig {
  shareType: string
  resourceId: number
  resourceName: string
  shareName: string
  sharePassword?: string
  expireTime?: string
  accessLevel: string
  allowDownload: boolean
  allowPreview: boolean
}

/**
 * 权限配置
 */
export interface PermissionConfig {
  resourceType: string
  resourceId: number
  resourceName: string
  permissions: {
    userId?: number
    roleId?: number
    permissionType: string
    grantType: string
  }[]
}

/**
 * 存储统计配置
 */
export interface StorageStatsConfig {
  totalSize: number
  usedSize: number
  fileCount: number
  folderCount: number
  usagePercentage: number
  totalSizeFormatted: string
  usedSizeFormatted: string
}
